﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using YJKGeometryFuncs;

namespace YJKCopyModel.CommonTrans
{
	public class ParallelLineComparer : IComparer<KeyValuePair<XYZ, Line>>
	{
		public ParallelLineComparer(XYZ ptRef)
		{
			this.m_ptRef = ptRef;
		}

		public int Compare(KeyValuePair<XYZ, Line> lhv, KeyValuePair<XYZ, Line> rhv)
		{
			double val = lhv.Key.DistanceTo(this.m_ptRef);
			double val2 = rhv.Key.DistanceTo(this.m_ptRef);
			bool flag = Geometry.IsEqual(val, val2);
			int result;
			if (flag)
			{
				XYZ xyz = Geometry.CalculateFootPoint(lhv.Value, this.m_ptRef);
				XYZ xyz2 = Geometry.CalculateFootPoint(rhv.Value, this.m_ptRef);
				double val3 = xyz.DistanceTo(this.m_ptRef);
				double val4 = xyz2.DistanceTo(this.m_ptRef);
				bool flag2 = Geometry.IsEqual(val3, val4);
				if (flag2)
				{
					result = 0;
				}
				else
				{
					bool flag3 = Geometry.LessThan(val3, val4);
					if (flag3)
					{
						result = -1;
					}
					else
					{
						result = 1;
					}
				}
			}
			else
			{
				bool flag4 = Geometry.LessThan(val, val2);
				if (flag4)
				{
					result = -1;
				}
				else
				{
					result = 1;
				}
			}
			return result;
		}

		private XYZ m_ptRef = null;
	}
}
